<template>
	<view class="wrap-cooperation-info">
		<view class="title f-30">合作</view>

		<view class="list flex">
			<block v-for="(item, index) in list" :key="index">
				<view
					class="item flex column align-center just-center"
					v-if="item.isShow"
					@click="onItem(item, index)"
				>
					<image class="img" :src="$staticImagePath(item.icon)" />

					<view class="name f-26"> {{ item.title }}</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			/**
			 * 用户信息
			 */
			userInfo: {
				type: Object,
				default: null,
			},
		},
		data() {
			return {
				
			};
		},
		computed: {
			list() {
				return [
					{
						title: "店铺管理",
						icon: "mine/dpgl.png",
						url: "/pages/mine/store/storeManager",
						status: 0,
						isShow: this.userInfo === null ? false : this.userInfo.apply_shop == 3,
					},
					{
						title: "商家入驻",
						icon: "mine/sjrz.png",
						url: "/pages/mine/store/apply",
						status: 1,
						isShow: this.userInfo === null ? false : (this.userInfo.apply_shop != 3 && this.userInfo.behoy_partner <= 0),
					},
					{
						title: "成为伙伴",
						icon: "mine/cwhb.png",
						url: "/pages/mine/partner/apply",
						status: 1,
						isShow: this.userInfo === null ? false : (this.userInfo.apply_shop != 3 && this.userInfo.behoy_partner <= 0),
					},
					{
						title: "伙伴体系",
						icon: "mine/cwhb.png",
						url: "/pages/mine/partner/partnerSystem",
						status: 0,
						isShow: this.userInfo === null ? false : (this.userInfo.behoy_partner > 0),
					},
					{
						title: "合作政策",
						icon: "mine/hzzc.png",
						url: "/pages/mine/partner/policyList",
						status: 1,
						isShow: true,
					},
					{
						title: "锁客码",
						icon: "mine/skm.png",
						url: "/pages/mine/partner/lockCode",
						status: 0,
						isShow: this.userInfo === null ? false : (this.userInfo.apply_shop == 3 || this.userInfo.behoy_partner > 0),
					},
				]
			}
		},
		methods: {
			/**
			 * 点击
			 */
			onItem(item, index) {
				if (item.title === "商家入驻") {
					if (this.userInfo !== null && this.userInfo.apply_shop == 2) {
						this.$st.show("申请审核中...");
						return;
					}
				} else if (item.title === "成为伙伴") {
					if (this.userInfo.behoy_partner == -1) {
						this.$st.show("申请审核中...");
						return;
					} else if (this.userInfo.behoy_partner == -2) {
						this.$st.show("申请失败，请重新申请");
					}
				}
				this.$jump.to(item.url);
			},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap-cooperation-info {
		width: 100%;
		overflow: hidden;
		background-color: white;
		border-radius: 16rpx;
		overflow: hidden;
		padding: 34rpx 0rpx 44rpx;

		.title {
			margin-left: 40rpx;
			color: #333333;
		}

		.list {
			margin-top: 32rpx;
			width: 100%;
			overflow: hidden;
			flex-wrap: wrap;

			.item {
				width: 25%;
				overflow: hidden;
				gap: 15rpx;

				.img {
					width: 70rpx;
					height: 70rpx;
				}

				.name {
					color: #121212;
				}
			}
		}
	}
</style>
